﻿using System.Text;
using System.Web;
using Pampa.CRUD.UI.CustomControls;
using Pampa.MVC.Fluent.CustomControls;
using Pampa.WebControls;

namespace Pampa.MVC.Fluent.Crud
{
    public class SaveButtonBuilder : IHtmlString
    {
        private readonly EntityEditSaveButton _saveButton;

        public SaveButtonBuilder(string entityEditId)
        {
            _saveButton = new EntityEditSaveButton();
            _saveButton.CssClass = "saveButton button";
            _saveButton.EntityEditID = entityEditId;
        }

        public SaveButtonBuilder Text(string text)
        {
            _saveButton.Text = text;
            return this;
        }

        public SaveButtonBuilder OnSuccess(string method)
        {
            _saveButton.OnSuccess = method;
            return this;
        }

        public string ToHtmlString()
        {
            var sb = new StringBuilder();
            sb.Append(_saveButton.Render());

            return sb.ToString();
        }
    }
}
